package com.ruoyi.orderview.utils;/*
package com.ruoyi.orderview.utils;

import com.ruoyi.orderview.domain.ProductionParam;
import com.ruoyi.orderview.mapper.ChartsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.*;

        * Author 许家森
        * Date 2022/2/24
        * Email 3448324670@qq.com


    已弃用
    查询出生产资料的所有type类型编号，逐个查询时间段前的类型初始值后，groupby两个字段分组，得到不同种类实时变化的数据，剔除同一种类在同一天变化的数据

@Component
public class AmountSelect {
    @Autowired
    private ChartsMapper chartsMapper;

    @Autowired
    private DateDispose dateDispose;

    public  List<Map<String,Double>> AmountSelects(ProductionParam productionParam){
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        String origintime = f.format(productionParam.getOrigintime());
        String endtime = f.format(dateDispose.DateDisposes(productionParam).getEndtime());

        List<Map<String,Double>> storagemap=new ArrayList<>();
        ProductionDistinguish  productionDistinguish = new ProductionDistinguish(productionParam);
        //seed_amount中的crop_type_id与其他表不同
        if(productionParam.getProductiontype().equals("seed")) {
            productionParam.setProductiontype("crop");
        }

        List<Integer> typelist=chartsMapper.selectAmountType(productionDistinguish.getStorage(), productionParam.getProductiontype() + "_type_id");

        if(typelist==null){
          return  null;
       }
        //List typelist=chartsMapper.selectAmountType(productionDistinguish.getStorage(), productionParam.getProductiontype() + "_type_id");

        int size=typelist.size();
        List<Double> storagelist=new ArrayList<>();
        double storage_amount=0;
        String datestring;
        double storageorigin =0;


        for (int inttype=0;inttype<size;inttype++){
           Map<Object,Object> map1=new HashMap<Object, Object>();
            map1=chartsMapper.selectUpdateOrigin(origintime,endtime,productionDistinguish.getStorage(),inttype+1,productionParam.getProductiontype()+"_type_id");
                if(map1==null) {
                    storagelist.add(inttype,0.0);
                }
                else {
                    storagelist.add(inttype, (double) map1.get("storage_amount"));
                }
            }


        List<Map<Object,Object>> list1=new ArrayList<>();
        list1=chartsMapper.selectUpdate(origintime,endtime,productionDistinguish.getStorage(),productionDistinguish.getStorage()+"_id",productionParam.getProductiontype()+"_type_id");

        Map<String,Double> map1=new HashMap<>();
        map1.put("2000-01-01",listmath(storagelist));
        storagemap.add(map1);


        if(list1!=null) {
            for (int i=0;i<list1.size();i++){

                Map<Object,Object> b=list1.get(i);
                datestring = b.get("update_time").toString();

                storage_amount = (double) b.get("storage_amount");

                if(i!=list1.size()-1 && datestring.equals(list1.get(i+1).get("update_time").toString())) {

                    Long c = (Long) b.get(productionParam.getProductiontype() + "_type_id");
                    int cc = c.intValue();
                    storagelist.set(cc - 1, storage_amount);
                    continue;
                }
                else {
                    Long c = (Long) b.get(productionParam.getProductiontype() + "_type_id");
                    int cc = c.intValue();
                    storagelist.set(cc - 1, storage_amount);

                    Map<String, Double> map2 = new HashMap<>();
                    map2.put(datestring, listmath(storagelist));
                    storagemap.add(map2);
                }
            }

            return storagemap;
        }
        else return null;


    }
    public double listmath(List a){
        double b = 0;
        for (int i=0;i<a.size();i++){
            b=b+(double)a.get(i);}
        return b;
    }

}
*/

